//============================================================================
// Name        : Main.cpp
// Author      : ja
// Version     :
// Copyright   : 
// Description :
//============================================================================

#include <iostream>
using namespace std;

#include "SerialPort.h"
#include "ModbusProtocol.h"
#include "Master.h"

#include "MemoryMaps.h"
#include "Thread.h"
#include "DataMonitor.cpp"

#include "ServerSocket.h"

#define DEVICE "/dev/ttyUSB0"
#define BAUD_RATE B9600
int main() {

	MemoryMaps * _mapManager = new MemoryMaps(2);
	_mapManager->initializeMaps(1);

	DataMonitor * consumer = new DataMonitor(Thread::PRIORITY_NORMAL,"DataMonitor",_mapManager);
	consumer->start();


	Master * master = new Master(Thread::PRIORITY_NORMAL,"ModbusMaster",_mapManager,DEVICE,BAUD_RATE);
	master->start();

	ServerSocket server(Thread::PRIORITY_NORMAL,"ServerMainThread",3000,_mapManager);
	server.run();


	sleep(100);

	cout << "" << endl; // prints 
	return 0;
}
